 begintownscript;
variables;
short choice,i;

body;
beginstate init_state;
i = 0;
while(char_ok(i) == 0){
	i = i + 1;
}
set_terrain(25,26,0);
reset_dialog();
add_dialog_str(0,"They led me down a flight of stairs into the basement of the warehouse. I had had a feeling from the start that I wasn't there to deliver to a warehouse foreman, and now I was growing increasingly uneasy about what really was going on there.",0);
add_dialog_str(1,"There was an armed guard at the base of the stairs, and another following behind me. They were dressed in a blue uniform with the image of a flying banner on their chests, unlike any guards I'd ever seen.",0);
add_dialog_str(2,"They didn't act much like guards either-- last time I checked guards watched the warehouse, not the basement.",0);
add_dialog_choice(0,"OK");
choice = run_dialog(1);
set_char_dialogue_pic(7,303,0);
activate_hidden_group(1);
activate_hidden_group(2);
activate_hidden_group(3);
break;

beginstate exit_state;
break;

beginstate start_state;
if((get_flag(12,6) == 1) && (get_flag(12,1) == 0)){
	message_dialog("A blue vested guard thankfully interrupted Samael's tirade. _Sir._","");
	message_dialog("_I have half a mind to--_","");
	message_dialog("_Sir-- SIR!_","");
	message_dialog("_WHAT THE HELL IS IT NOW?_","");
	message_dialog("_Sir, I have urgent news._","");
	message_dialog("_It will have to wait. I am dealing with this... this... DISGRACE... right now._","");
	message_dialog("_I'm sorry sir, but it can not wait. It is very urgent._","");
	message_dialog("Samael finally stood and followed the messenger through the door to the north, glaring daggers back at me the whole way. Most of the guards filed out behind him, leaving just me, two guards, and the man in the chair next to me, who had yet to speak.","");
	erase_char(1001);
	activate_hidden_group(2);
	set_flag(12,1,1);
}
if((get_flag(12,3) > 0) && (get_flag(12,4) == 0)){
	set_flag(12,4,1);
	set_character_facing(i,2);
	set_character_pose(i,1);
	force_instant_terrain_redraw();
	play_sound(157);
	pause(2);

	set_character_pose(i,2);
	force_instant_terrain_redraw();

	play_sound(-29);
	set_character_pose(14,11);
	force_instant_terrain_redraw();
	pause(1);

	set_character_pose(14,12);
	force_instant_terrain_redraw();
	pause(1);

	set_character_pose(14,13);
	force_instant_terrain_redraw();
	pause(1);

	set_character_pose(14,14);
	force_instant_terrain_redraw();
	pause(1);
	erase_char(14);

	message_dialog("The guard crumpled to the floor with a broken neck.","_Untie me, quickly!_ I hadn't even realized he was bound, it was hard to see the cords beneath his robe, and in the darkness it was hard to tell that he wasn't sitting naturally.");
	message_dialog("I had pulled out my dagger and bent to slice his bonds, but he beat me to it. Suddenly the cords withered and burst into flame before falling to the floor in a pile of ash. A wizard! Perhaps I'd have some help in the coming fight.","");
	reset_dialog();
	add_dialog_str(0,"Suddenly the door was thrown open and Samael came striding in, his retinue in tow.",0);
	add_dialog_str(1,"_.... tell them to hold off the Watch long enough for us to escape with the teleportal, and then to make their own exit through the escape tunnels. Execute these fools, we cannot take them wi--_",0);
	add_dialog_str(2,"Suddenly he noticed that we were standing and one of his guards lay dead at my feet.",0);
	activate_hidden_group(1);
	activate_hidden_group(3);
	erase_char(7);
	activate_hidden_group(4);
	reset_dialog();
	add_dialog_str(0,"_I do not have time for this nonsense. I do not know what you think to gain by striking at my men, but you are clearly outmatched and outnumbered_",0);
	add_dialog_str(1,"_ Give me the package and we will allow you to live. If you resist you will die. If you give it to me we will go our way and leave you for the Watch to find-- everybody goes home happy._",0);
	add_dialog_choice(0,"Tempting-- but I don't think so.");
	choice = run_dialog(1);
	message_dialog("_Do you take satisfaction in trying to ruin everything I attempt? It will be a pleasure to strip the flesh from your worthless bones._","");
	set_attitude(1001,10);
}
if((num_chars_in_group(1) == 0) && (get_flag(12,4) > 0) && (get_flag(12,5) == 0)){
	set_flag(12,5,1);
	reset_dialog();
	add_dialog_str(0,"_Thank you friend,_ the mage gasped as the last of the blue armored men died. _But we aren't out yet. The City Watch has apparently found out about these men and is on the way._",0);
	add_dialog_str(1,"_I don't know if you'd rather wait for the Watch than use the teleportation rod, but I've had some-- troubles-- with the Watch lately, so if you don't mind handing me the package?_",0);
	add_dialog_choice(0,"I'll come too.");
	choice = run_dialog(1);

	reset_dialog();
	add_dialog_str(0,"_Alright-- the package then? Thank you._",0);
	add_dialog_str(1,"_This is pretty standard stuff,_ he mumbled as he looked over the contents of the package, a slim ivory rod with a metal head. _Yeah, I've used one of these... I wonder where they have it configured for..... Hmmmmm...._",0);
	add_dialog_choice(0,"You know how to work this thing or not?");
	choice = run_dialog(1);

	reset_dialog();
	add_dialog_str(0,"_I know how. I'm just not sure where it'll take us..... Yeah, I'm reasonably sure I know how to use this...._",0);
	add_dialog_str(1,"_Here take a hold here. A bit lower, leave room for my hand as well. Good. Now hang on._",0);
	add_dialog_str(2,"Suddenly he turned to look at me, _You know, I don't think I caught your name-- I'm Emery by the way. You know, just so I don't die next to a stranger._",0);
	add_dialog_choice(0,"It's Theo-- you know, all this talk of dying is making me have second thoughts...");
	choice = run_dialog(1);

	message_dialog("Too late. Emery had already pressed the button on the teleportation rod.","_Cross your fingers, Theo-- no, on second thought just keep a good grip on the rod. DON'T cross your fingers._ And with that the magical energies enveloped us.");
	play_sound(10);
	relocate_character(i,1,1);
	force_view_center(1,1);
	force_instant_terrain_Redraw();
	reset_dialog();
	add_dialog_str(0,"Have you ever wondered how painful it'd be to die in a teleportation accident? Well I hadn't before that day, but at that moment it was a pretty big concern. The concept is a pretty grizzly one.",0);
	add_dialog_str(1,"Thankfully I didn't find out.",0);
	add_dialog_choice(0,"OK");
	choice = run_dialog(1);
}

break;

beginstate 10;
message_dialog("I had come this far, I wasn't turning back now. This was an important delivery, I couldn't just not show up at all.","");
block_entry(1);
break;

beginstate 11;
if(get_flag(12,0) == 0){
	block_entry(1);
	play_sound(59);
	flip_terrain(25,32);
	set_flag(12,0,1);
	message_dialog("I was ushered into a small, dimly lit chamber. The door was shut behind me, and I could hear a bolt being slid in place.","Ahead of me was a table with three chairs. On one side sat an armored man with the same flag emblem on his chest as the guards. On the other side was a man in dirty blue robes, and an empty chair.");
	message_dialog("_So the courier finally arrives. Take a seat._","As I walked across the room I could see the outlines of more men standing in the shadows at the edge of the room. I'd dealt with some strange customers before, but I must admit the whole thing was disconcerting even for me.");
	relocate_character(i,26,26);
	set_character_pose(i,5);
	force_view_center(26,26);
	force_instant_terrain_redraw();
	pause(1);
	begin_talk_mode(1);
}
else{
	block_entry(1);
	message_dialog("The doors had been locked, I was stuck.","");
}
break;

beginstate 12;
if(get_flag(12,4) == 0)
	block_entry(1);
break;

beginstate 20;
message_dialog("_Hmmm.... That's not how the story went...._","");
end_scenario(0);
break;

beginstate 21;
move_to_new_town(13,12,18);
//move_to_new_town(5,12,18);
break;


beginstate 100;
block_entry(1);
break;